<?php
/*
 * @Author: your name
 * @Date: 2022-01-14 14:20:00
 * @LastEditTime: 2022-01-14 14:36:56
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \20220114\index.php
 */
header('Content-Type: text/html;charset=utf-8');
header('Access-Control-Allow-Origin:*'); // *代表允许任何网址请求
header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'); // 允许请求的类型
header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
header('Access-Control-Allow-Headers: Content-Type,Content-Length,Accept-Encoding,X-Requested-with, Origin'); // 设置允许自定义请求头的字段
// echo '首页';
$array = [
    ['id' => 1, 'brand' => '华为', 'price' => 5000, 'type' => '华为p50'],
    ['id' => 2, 'brand' => '苹果', 'price' => 6000, 'type' => 'iphone 13'],
    ['id' => 3, 'brand' => '小米', 'price' => 3699, 'type' => '小米12'],
    ['id' => 4, 'brand' => '魅族', 'price' => 3500, 'type' => '魅族18'],
    ['id' => 5, 'brand' => 'oppo', 'price' => 3200, 'type' => 'oppo 18'],
];
// echo $array[0]['brand'];
// 把数组转化为json格式
$array = json_encode($array);
// 输出数据
echo $array;